#!/usr/bin/env python
# -*- coding: utf-8 -*-
from django.db import models

# Create your models here.
class Tweet(models.Model):
    text = models.CharField(max_length=140)
    author_email = models.CharField(max_length=200)
    created_at = models.DateTimeField(auto_now_add=True)
    published_at = models.DateTimeField(null=True)
    STATE_CHOICES = (
        ('pending','pending'),
        ('published','published'),
        ('rejected','rejected'),
    )
    state = models.CharField(max_length=15,choices=STATE_CHOICES)
    def __unicode__(self):
        return self.text
    class Meta:
        permissions = (
            ("can_approve_or_reject_tweet","Can approve of reject tweets"),
        )   #permissions主要是为了在Django Admin管理模块下使用的，如果你设置了这个属性可以让指定的方法权限描述更清晰可读。

class Comment(models.Model):
    tweet = models.ForeignKey(Tweet)
    text = models.CharField(max_length=200)
    created_at = models.DateTimeField(auto_now_add=True)
    def __unicode__(self):
        return self.text
